package Anagram;

import java.io.*;
import java.util.ArrayList;
import java.util.Collection;

/**
 * User: Vitalii Serdiuk
 * Date: 03.12.13 13:41
 */
public class FileReader {
    public Collection<String> readFile(String filePath, String encoding) {

        Collection<String> fileLine = new ArrayList<String>();

        BufferedReader in = null;
        try {
            in = new BufferedReader(
                    new InputStreamReader(
                            new FileInputStream(new File(filePath)), encoding));

            String str;
            while ((str = in.readLine()) != null) {
                fileLine.add(str);
            }

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return fileLine;
    }
}
